<html lang="zh-cn">
<head>
{% include "tdm_include_head_template.html" %}
<link href="/static/css/bootstrap-multiselect.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="/static/js/bootstrap-multiselect.js"></script>
<script type="text/javascript">
  $(document).ready(function() {
    $.each($("select"), function(i, obj) {
      $(obj).multiselect({
        includeSelectAllOption: true,
        maxHeight: 150
      });
    });
    //$('#example-getting-started').multiselect();
  });
</script>
</head>

<body class=" theme-blue">
{% include "tdm_include_navbar_template.html" %}

<div class="container">
  <br/>
  {% include "tdm_include_error_template.html" %}

  {% include "tdm_include_admin_page_template.html" %}

  <div class="form-context">
  <form id="alert_email" action="/tdm/admin/alert/" method="post" class="form-horizontal" role="form">
    <div class="form-group">
      <label for="alert_email" class="col-sm-2 control-label">告警发送邮箱</label>
      <div class="col-sm-4">
        <input type="email" class="form-control" name="alert_email" placeholder="alert_send@mail.com" value="{{alert_cfg.alert_mail_user}}">
      </div>
    </div>
    <div class="form-group">
      <label for="email_passwd" class="col-sm-2 control-label">密码</label>
      <div class="col-sm-4">
        <input type="password" class="form-control" name="email_passwd" value="{{alert_cfg.alert_mail_pass}}">
      </div>
    </div>

    {% for mod in mod_list %}
    <div class="row">
      <div class="col-sm-2 col-sm-offset-2">
        <div class="checkbox">
          <label>
            <input type="checkbox" name="email_send_list" value="{{mod.name}}" {% if mod.alert_enable %}checked="checked"{% endif %}>
            {{mod.alias}}报警
          </label>
        </div>
      </div>
      <div class="col-sm-2">
        <select id="{{mod.name}}_officers" name="{{mod.name}}_officers" multiple="multiple">
          {% for user in user_list %}
          <option value="{{user.name}}" {% if user in mod.officers %}selected="selected"{% endif %}>{{user.name}}</option>
          {% endfor %}
        </select>
      </div>
      <div class="col-sm-6">
        <div class="checkbox">
          <label>
            <input type="checkbox" name="alert_by_city" value="{{mod.name}}" {% if mod.alert_by_city %}checked="checked"{% endif %}>
            按用户城市发送报警
          </label>
        </div>
      </div>
    </div>
    {% endfor %}

    <div class="form-group">
      <div class="col-sm-4 col-sm-offset-2">
        <button type="submit" name="op" value="alert_config" class="btn btn-primary">配置</button>
      </div>
    </div>
    <hr/>
    <div class="form-group">
      <label for="alert_rcvtest_email" class="col-sm-2 control-label">告警接收测试邮箱</label>
      <div class="col-sm-4">
        <input type="email" class="form-control" name="alert_rcvtest_email" placeholder="test1@mail.com;test2@mail.com">
      </div>
    </div>
    <div class="form-group">
      <div class="col-sm-4 col-sm-offset-2">
        <button type="submit" name="op" value="email_test" class="btn btn-primary">发送测试邮件</button>
      </div>
    </div>

  </form>
  </div>

{% include "tdm_include_footer_template.html" %}
</div>
</body>
</html>